package com.ruoyi.common.tools.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum StatTimeEnum {
	//year 年 quarter 季度 month 月 week 周
	year("year" , 365),
	quarter("quarter" , 90),
	month("month" , 30),
	week("week" , 7),
	currDay("currDay" , 0)
	;
	
	private String timeType;
	
	private int day;
	
	public static StatTimeEnum getStatTimeEnum(String timeType) {
		for (StatTimeEnum e : StatTimeEnum.values()) {
			if (e.getTimeType().equals(timeType)) {
				return e;
			}
		}
		return null;
	}
	
	public static int getDayByTimeType(String timeType) {
		StatTimeEnum e = getStatTimeEnum(timeType);
		if (null != e) {
			return e.getDay();
		}else {
			return 0;
		}
	}
}
